import time
from selenium import webdriver
from selenium.webdriver.common.by import By

#打开谷歌浏览器
driver = webdriver.Chrome()
#输入百度网站
time.sleep(2)
driver.get('https://www.baidu.com')

#获取输入框关键字
time.sleep(2)

kw =driver.find_element(By.ID,'kw')
# 输入文本内容 webdriver.send_keys
kw.send_keys('天气预报')

#获取百度按钮
time.sleep(2)
su = driver.find_element(By.ID,'su')
#点击 webelement.click
su.click()

time.sleep(2)
print(driver.title)

# 检查’python‘关键字是否在标题中
if 'python' in driver.title:
    print('ok')
else:
    print('no')

time.sleep(5)
driver.quit()
